home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / progtool / c / gcc / gcc258s.zoo / gcc.info-2 < prev    next >
Encoding:
GNU Info File  |  1993-11-30  |  41.8 KB  |  1,028 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Published by the Free Software Foundation 675 Massachusetts Avenue
  7. Cambridge, MA 02139 USA
  8.  
  9.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  10.  
  11.    Permission is granted to make and distribute verbatim copies of this
  12. manual provided the copyright notice and this permission notice are
  13. preserved on all copies.
  14.  
  15.    Permission is granted to copy and distribute modified versions of
  16. this manual under the conditions for verbatim copying, provided also
  17. that the sections entitled "GNU General Public License" and "Protect
  18. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  19. original, and provided that the entire resulting derived work is
  20. distributed under the terms of a permission notice identical to this
  21. one.
  22.  
  23.    Permission is granted to copy and distribute translations of this
  24. manual into another language, under the above conditions for modified
  25. versions, except that the sections entitled "GNU General Public
  26. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  27. permission notice, may be included in translations approved by the Free
  28. Software Foundation instead of in the original English.
  29.  
  30. File: gcc.info,  Node: Invoking G++,  Next: C Dialect Options,  Prev: Overall Options,  Up: Invoking GCC
  31.  
  32. Compiling C++ Programs
  33. ======================
  34.  
  35.    C++ source files conventionally use one of the suffixes `.C', `.cc',
  36. or `.cxx'; preprocessed C++ files use the suffix `.ii'.  GNU CC
  37. recognizes files with these names and compiles them as C++ programs
  38. even if you call the compiler the same way as for compiling C programs
  39. (usually with the name `gcc').
  40.  
  41.    However, C++ programs often require class libraries as well as a
  42. compiler that understands the C++ language--and under some
  43. circumstances, you might want to compile programs from standard input,
  44. or otherwise without a suffix that flags them as C++ programs.  `g++'
  45. is a shell script that calls GNU CC with the default language set to
  46. C++, and automatically specifies linking against the GNU class library
  47. libg++.  (1) On many systems, the script `g++' is also installed with
  48. the name `c++'.
  49.  
  50.    When you compile C++ programs, you may specify many of the same
  51. command-line options that you use for compiling programs in any
  52. language; or command-line options meaningful for C and related
  53. languages; or options that are meaningful only for C++ programs.  *Note
  54. Options Controlling C Dialect: C Dialect Options, for explanations of
  55. options for languages related to C.  *Note Options Controlling C++
  56. Dialect: C++ Dialect Options, for explanations of options that are
  57. meaningful only for C++ programs.
  58.  
  59.    ---------- Footnotes ----------
  60.  
  61.    (1)  Prior to release 2 of the compiler, there was a separate `g++'
  62. compiler.  That version was based on GNU CC, but not integrated with
  63. it.  Versions of `g++' with a `1.XX' version number--for example, `g++'
  64. version 1.37 or 1.42--are much less reliable than the versions
  65. integrated with GCC 2.  Moreover, combining G++ `1.XX' with a version 2
  66. GCC will simply not work.
  67.  
  68. File: gcc.info,  Node: C Dialect Options,  Next: C++ Dialect Options,  Prev: Invoking G++,  Up: Invoking GCC
  69.  
  70. Options Controlling C Dialect
  71. =============================
  72.  
  73.    The following options control the dialect of C (or languages derived
  74. from C, such as C++ and Objective C) that the compiler accepts:
  75.  
  76. `-ansi'
  77.      Support all ANSI standard C programs.
  78.  
  79.      This turns off certain features of GNU C that are incompatible
  80.      with ANSI C, such as the `asm', `inline' and `typeof' keywords, and
  81.      predefined macros such as `unix' and `vax' that identify the type
  82.      of system you are using.  It also enables the undesirable and
  83.      rarely used ANSI trigraph feature, and disallows `$' as part of
  84.      identifiers.
  85.  
  86.      The alternate keywords `__asm__', `__extension__', `__inline__'
  87.      and `__typeof__' continue to work despite `-ansi'.  You would not
  88.      want to use them in an ANSI C program, of course, but it useful to
  89.      put them in header files that might be included in compilations
  90.      done with `-ansi'.  Alternate predefined macros such as `__unix__'
  91.      and `__vax__' are also available, with or without `-ansi'.
  92.  
  93.      The `-ansi' option does not cause non-ANSI programs to be rejected
  94.      gratuitously.  For that, `-pedantic' is required in addition to
  95.      `-ansi'.  *Note Warning Options::.
  96.  
  97.      The macro `__STRICT_ANSI__' is predefined when the `-ansi' option
  98.      is used.  Some header files may notice this macro and refrain from
  99.      declaring certain functions or defining certain macros that the
  100.      ANSI standard doesn't call for; this is to avoid interfering with
  101.      any programs that might use these names for other things.
  102.  
  103.      The functions `alloca', `abort', `exit', and `_exit' are not
  104.      builtin functions when `-ansi' is used.
  105.  
  106. `-fno-asm'
  107.      Do not recognize `asm', `inline' or `typeof' as a keyword.  These
  108.      words may then be used as identifiers.  You can use the keywords
  109.      `__asm__', `__inline__' and `__typeof__' instead.  `-ansi' implies
  110.      `-fno-asm'.
  111.  
  112. `-fno-builtin'
  113.      Don't recognize builtin functions that do not begin with two
  114.      leading underscores.  Currently, the functions affected include
  115.      `abort', `abs', `alloca', `cos', `exit', `fabs', `ffs', `labs',
  116.      `memcmp', `memcpy', `sin', `sqrt', `strcmp', `strcpy', and
  117.      `strlen'.
  118.  
  119.      GCC normally generates special code to handle certain builtin
  120.      functions more efficiently; for instance, calls to `alloca' may
  121.      become single instructions that adjust the stack directly, and
  122.      calls to `memcpy' may become inline copy loops.  The resulting
  123.      code is often both smaller and faster, but since the function
  124.      calls no longer appear as such, you cannot set a breakpoint on
  125.      those calls, nor can you change the behavior of the functions by
  126.      linking with a different library.
  127.  
  128.      The `-ansi' option prevents `alloca' and `ffs' from being builtin
  129.      functions, since these functions do not have an ANSI standard
  130.      meaning.
  131.  
  132. `-trigraphs'
  133.      Support ANSI C trigraphs.  You don't want to know about this
  134.      brain-damage.  The `-ansi' option implies `-trigraphs'.
  135.  
  136. `-traditional'
  137.      Attempt to support some aspects of traditional C compilers.
  138.      Specifically:
  139.  
  140.         * All `extern' declarations take effect globally even if they
  141.           are written inside of a function definition.  This includes
  142.           implicit declarations of functions.
  143.  
  144.         * The newer keywords `typeof', `inline', `signed', `const' and
  145.           `volatile' are not recognized.  (You can still use the
  146.           alternative keywords such as `__typeof__', `__inline__', and
  147.           so on.)
  148.  
  149.         * Comparisons between pointers and integers are always allowed.
  150.  
  151.         * Integer types `unsigned short' and `unsigned char' promote to
  152.           `unsigned int'.
  153.  
  154.         * Out-of-range floating point literals are not an error.
  155.  
  156.         * Certain constructs which ANSI regards as a single invalid
  157.           preprocessing number, such as `0xe-0xd', are treated as
  158.           expressions instead.
  159.  
  160.         * String "constants" are not necessarily constant; they are
  161.           stored in writable space, and identical looking constants are
  162.           allocated separately.  (This is the same as the effect of
  163.           `-fwritable-strings'.)
  164.  
  165.         * All automatic variables not declared `register' are preserved
  166.           by `longjmp'.  Ordinarily, GNU C follows ANSI C: automatic
  167.           variables not declared `volatile' may be clobbered.
  168.  
  169.         * In the preprocessor, comments convert to nothing at all,
  170.           rather than to a space.  This allows traditional token
  171.           concatenation.
  172.  
  173.         * In the preprocessor, macro arguments are recognized within
  174.           string constants in a macro definition (and their values are
  175.           stringified, though without additional quote marks, when they
  176.           appear in such a context).  The preprocessor always considers
  177.           a string constant to end at a newline.
  178.  
  179.         * The predefined macro `__STDC__' is not defined when you use
  180.           `-traditional', but `__GNUC__' is (since the GNU extensions
  181.           which `__GNUC__' indicates are not affected by
  182.           `-traditional').  If you need to write header files that work
  183.           differently depending on whether `-traditional' is in use, by
  184.           testing both of these predefined macros you can distinguish
  185.           four situations: GNU C, traditional GNU C, other ANSI C
  186.           compilers, and other old C compilers.  *Note Standard
  187.           Predefined Macros: (cpp.info)Standard Predefined, for more
  188.           discussion of these and other predefined macros.
  189.  
  190.         * The preprocessor considers a string constant to end at a
  191.           newline (unless the newline is escaped with `\').  (Without
  192.           `-traditional', string constants can contain the newline
  193.           character as typed.)
  194.  
  195.         * The character escape sequences `\x' and `\a' evaluate as the
  196.           literal characters `x' and `a' respectively.  Without
  197.           `-traditional', `\x' is a prefix for the hexadecimal
  198.           representation of a character, and `\a' produces a bell.
  199.  
  200.         * In C++ programs, assignment to `this' is permitted with
  201.           `-traditional'.  (The option `-fthis-is-variable' also has
  202.           this effect.)
  203.  
  204.      You may wish to use `-fno-builtin' as well as `-traditional' if
  205.      your program uses names that are normally GNU C builtin functions
  206.      for other purposes of its own.
  207.  
  208. `-traditional-cpp'
  209.      Attempt to support some aspects of traditional C preprocessors.
  210.      This includes the last three items in the table immediately above,
  211.      but none of the other effects of `-traditional'.
  212.  
  213. `-fcond-mismatch'
  214.      Allow conditional expressions with mismatched types in the second
  215.      and third arguments.  The value of such an expression is void.
  216.  
  217. `-funsigned-char'
  218.      Let the type `char' be unsigned, like `unsigned char'.
  219.  
  220.      Each kind of machine has a default for what `char' should be.  It
  221.      is either like `unsigned char' by default or like `signed char' by
  222.      default.
  223.  
  224.      Ideally, a portable program should always use `signed char' or
  225.      `unsigned char' when it depends on the signedness of an object.
  226.      But many programs have been written to use plain `char' and expect
  227.      it to be signed, or expect it to be unsigned, depending on the
  228.      machines they were written for.  This option, and its inverse, let
  229.      you make such a program work with the opposite default.
  230.  
  231.      The type `char' is always a distinct type from each of `signed
  232.      char' or `unsigned char', even though its behavior is always just
  233.      like one of those two.
  234.  
  235. `-fsigned-char'
  236.      Let the type `char' be signed, like `signed char'.
  237.  
  238.      Note that this is equivalent to `-fno-unsigned-char', which is the
  239.      negative form of `-funsigned-char'.  Likewise, the option
  240.      `-fno-signed-char' is equivalent to `-funsigned-char'.
  241.  
  242. `-fsigned-bitfields'
  243. `-funsigned-bitfields'
  244. `-fno-signed-bitfields'
  245. `-fno-unsigned-bitfields'
  246.      These options control whether a bitfield is signed or unsigned,
  247.      when the declaration does not use either `signed' or `unsigned'.
  248.      By default, such a bitfield is signed, because this is consistent:
  249.      the basic integer types such as `int' are signed types.
  250.  
  251.      However, when `-traditional' is used, bitfields are all unsigned
  252.      no matter what.
  253.  
  254. `-fwritable-strings'
  255.      Store string constants in the writable data segment and don't
  256.      uniquize them.  This is for compatibility with old programs which
  257.      assume they can write into string constants.  The option
  258.      `-traditional' also has this effect.
  259.  
  260.      Writing into string constants is a very bad idea; "constants"
  261.      should be constant.
  262.  
  263. `-fallow-single-precision'
  264.      Do not promote single precision math operations to double
  265.      precision, even when compiling with `-traditional'.
  266.  
  267.      Traditional K&R C promotes all floating point operations to double
  268.      precision, regardless of the sizes of the operands.   On the
  269.      architecture for which you are compiling, single precision may be
  270.      faster than double precision.   If you must use `-traditional',
  271.      but want to use single precision operations when the operands are
  272.      single precision, use this option.   This option has no effect
  273.      when compiling with ANSI or GNU C conventions (the default).
  274.  
  275. File: gcc.info,  Node: C++ Dialect Options,  Next: Warning Options,  Prev: C Dialect Options,  Up: Invoking GCC
  276.  
  277. Options Controlling C++ Dialect
  278. ===============================
  279.  
  280.    This section describes the command-line options that are only
  281. meaningful for C++ programs; but you can also use most of the GNU
  282. compiler options regardless of what language your program is in.  For
  283. example, you might compile a file `firstClass.C' like this:
  284.  
  285.      g++ -g -felide-constructors -O -c firstClass.C
  286.  
  287. In this example, only `-felide-constructors' is an option meant only
  288. for C++ programs; you can use the other options with any language
  289. supported by GNU CC.
  290.  
  291.    Here is a list of options that are *only* for compiling C++ programs:
  292.  
  293. `-fall-virtual'
  294.      Treat all possible member functions as virtual, implicitly.  All
  295.      member functions (except for constructor functions and `new' or
  296.      `delete' member operators) are treated as virtual functions of the
  297.      class where they appear.
  298.  
  299.      This does not mean that all calls to these member functions will
  300.      be made through the internal table of virtual functions.  Under
  301.      some circumstances, the compiler can determine that a call to a
  302.      given virtual function can be made directly; in these cases the
  303.      calls are direct in any case.
  304.  
  305. `-fdollars-in-identifiers'
  306.      Accept `$' in identifiers.  You can also explicitly prohibit use of
  307.      `$' with the option `-fno-dollars-in-identifiers'.  (GNU C++
  308.      allows `$' by default on some target systems but not others.)
  309.      Traditional C allowed the character `$' to form part of
  310.      identifiers.  However, ANSI C and C++ forbid `$' in identifiers.
  311.  
  312. `-felide-constructors'
  313.      Elide constructors when this seems plausible.  With this option,
  314.      GNU C++ initializes `y' directly from the call to `foo' without
  315.      going through a temporary in the following code:
  316.  
  317.           A foo ();
  318.           A y = foo ();
  319.  
  320.      Without this option, GNU C++ (1) initializes `y' by calling the
  321.      appropriate constructor for type `A'; (2) assigns the result of
  322.      `foo' to a temporary; and, finally, (3) replaces the initial value
  323.      of `y' with the temporary.
  324.  
  325.      The default behavior (`-fno-elide-constructors') is specified by
  326.      the draft ANSI C++ standard.  If your program's constructors have
  327.      side effects, `-felide-constructors' can change your program's
  328.      behavior, since some constructor calls may be omitted.
  329.  
  330. `-fenum-int-equiv'
  331.      Permit implicit conversion of `int' to enumeration types.  Normally
  332.      GNU C++ allows conversion of `enum' to `int', but not the other
  333.      way around.
  334.  
  335. `-fexternal-templates'
  336.      Produce smaller code for template declarations, by generating only
  337.      a single copy of each template function where it is defined.  To
  338.      use this option successfully, you must also mark all files that
  339.      use templates with either `#pragma implementation' (the
  340.      definition) or `#pragma interface' (declarations).  *Note
  341.      Declarations and Definitions in One Header: C++ Interface, for more
  342.      discussion of these pragmas.
  343.  
  344.      When your code is compiled with `-fexternal-templates', all
  345.      template instantiations are external.  You must arrange for all
  346.      necessary instantiations to appear in the implementation file; you
  347.      can do this with a `typedef' that references each instantiation
  348.      needed.  Conversely, when you compile using the default option
  349.      `-fno-external-templates', all template instantiations are
  350.      explicitly internal.
  351.  
  352.      You do not need to specify `-fexternal-templates' when compiling a
  353.      file that does not define and instantiate templates used in other
  354.      files, even if your file *uses* templates defined in other files
  355.      that are compiled with `-fexternal-templates'.  The only side
  356.      effect is an increase in object size for each file that you
  357.      compile without `-fexternal-templates'.
  358.  
  359. `-fmemoize-lookups'
  360. `-fsave-memoized'
  361.      Use heuristics to compile faster.  These heuristics are not
  362.      enabled by default, since they are only effective for certain
  363.      input files.  Other input files compile more slowly.
  364.  
  365.      The first time the compiler must build a call to a member function
  366.      (or reference to a data member), it must (1) determine whether the
  367.      class implements member functions of that name; (2) resolve which
  368.      member function to call (which involves figuring out what sorts of
  369.      type conversions need to be made); and (3) check the visibility of
  370.      the member function to the caller.  All of this adds up to slower
  371.      compilation.  Normally, the second time a call is made to that
  372.      member function (or reference to that data member), it must go
  373.      through the same lengthy process again.  This means that code like
  374.      this:
  375.  
  376.           cout << "This " << p << " has " << n << " legs.\n";
  377.  
  378.      makes six passes through all three steps.  By using a software
  379.      cache, a "hit" significantly reduces this cost.  Unfortunately,
  380.      using the cache introduces another layer of mechanisms which must
  381.      be implemented, and so incurs its own overhead.
  382.      `-fmemoize-lookups' enables the software cache.
  383.  
  384.      Because access privileges (visibility) to members and member
  385.      functions may differ from one function context to the next, G++
  386.      may need to flush the cache.  With the `-fmemoize-lookups' flag,
  387.      the cache is flushed after every function that is compiled.  The
  388.      `-fsave-memoized' flag enables the same software cache, but when
  389.      the compiler determines that the context of the last function
  390.      compiled would yield the same access privileges of the next
  391.      function to compile, it preserves the cache.  This is most helpful
  392.      when defining many member functions for the same class: with the
  393.      exception of member functions which are friends of other classes,
  394.      each member function has exactly the same access privileges as
  395.      every other, and the cache need not be flushed.
  396.  
  397. `-fno-strict-prototype'
  398.      Treat a function declaration with no arguments, such as `int foo
  399.      ();', as C would treat it--as saying nothing about the number of
  400.      arguments or their types.  Normally, such a declaration in C++
  401.      means that the function `foo' takes no arguments.
  402.  
  403. `-fnonnull-objects'
  404.      Assume that objects reached through references are not null.
  405.  
  406.      Normally, GNU C++ makes conservative assumptions about objects
  407.      reached through references.  For example, the compiler must check
  408.      that `a' is not null in code like the following:
  409.  
  410.           obj &a = g ();
  411.           a.f (2);
  412.  
  413.      Checking that references of this sort have non-null values requires
  414.      extra code, however, and it is unnecessary for many programs.  You
  415.      can use `-fnonnull-objects' to omit the checks for null, if your
  416.      program doesn't require checking.
  417.  
  418. `-fthis-is-variable'
  419.      Permit assignment to `this'.  The incorporation of user-defined
  420.      free store management into C++ has made assignment to `this' an
  421.      anachronism.  Therefore, by default it is invalid to assign to
  422.      `this' within a class member function; that is, GNU C++ treats the
  423.      type of `this' in a member function of class `X' to be `X *const'.
  424.      However, for backwards compatibility, you can make it valid with
  425.      `-fthis-is-variable'.
  426.  
  427. `-nostdinc++'
  428.      Do not search for header files in the standard directories
  429.      specific to C++, but do still search the other standard
  430.      directories.  (This option is used when building libg++.)
  431.  
  432. `-traditional'
  433.      For C++ programs (in addition to the effects that apply to both C
  434.      and C++), this has the same effect as `-fthis-is-variable'.  *Note
  435.      Options Controlling C Dialect: C Dialect Options.
  436.  
  437.    In addition, these optimization, warning, and code generation options
  438. have meanings only for C++ programs:
  439.  
  440. `-fno-default-inline'
  441.      Do not assume `inline' for functions defined inside a class scope.
  442.      *Note Options That Control Optimization: Optimize Options.
  443.  
  444. `-Wenum-clash'
  445. `-Woverloaded-virtual'
  446. `-Wtemplate-debugging'
  447.      Warnings that apply only to C++ programs.  *Note Options to
  448.      Request or Suppress Warnings: Warning Options.
  449.  
  450. `+eN'
  451.      Control how virtual function definitions are used, in a fashion
  452.      compatible with `cfront' 1.x.  *Note Options for Code Generation
  453.      Conventions: Code Gen Options.
  454.  
  455. File: gcc.info,  Node: Warning Options,  Next: Debugging Options,  Prev: C++ Dialect Options,  Up: Invoking GCC
  456.  
  457. Options to Request or Suppress Warnings
  458. =======================================
  459.  
  460.    Warnings are diagnostic messages that report constructions which are
  461. not inherently erroneous but which are risky or suggest there may have
  462. been an error.
  463.  
  464.    You can request many specific warnings with options beginning `-W',
  465. for example `-Wimplicit' to request warnings on implicit declarations.
  466. Each of these specific warning options also has a negative form
  467. beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'.
  468. This manual lists only one of the two forms, whichever is not the
  469. default.
  470.  
  471.    These options control the amount and kinds of warnings produced by
  472. GNU CC:
  473.  
  474. `-fsyntax-only'
  475.      Check the code for syntax errors, but don't do anything beyond
  476.      that.
  477.  
  478. `-w'
  479.      Inhibit all warning messages.
  480.  
  481. `-Wno-import'
  482.      Inhibit warning messages about the use of `#import'.
  483.  
  484. `-pedantic'
  485.      Issue all the warnings demanded by strict ANSI standard C; reject
  486.      all programs that use forbidden extensions.
  487.  
  488.      Valid ANSI standard C programs should compile properly with or
  489.      without this option (though a rare few will require `-ansi').
  490.      However, without this option, certain GNU extensions and
  491.      traditional C features are supported as well.  With this option,
  492.      they are rejected.
  493.  
  494.      `-pedantic' does not cause warning messages for use of the
  495.      alternate keywords whose names begin and end with `__'.  Pedantic
  496.      warnings are also disabled in the expression that follows
  497.      `__extension__'.  However, only system header files should use
  498.      these escape routes; application programs should avoid them.
  499.      *Note Alternate Keywords::.
  500.  
  501.      This option is not intended to be useful; it exists only to satisfy
  502.      pedants who would otherwise claim that GNU CC fails to support the
  503.      ANSI standard.
  504.  
  505.      Some users try to use `-pedantic' to check programs for strict ANSI
  506.      C conformance.  They soon find that it does not do quite what they
  507.      want: it finds some non-ANSI practices, but not all--only those
  508.      for which ANSI C *requires* a diagnostic.
  509.  
  510.      A feature to report any failure to conform to ANSI C might be
  511.      useful in some instances, but would require considerable
  512.      additional work and would be quite different from `-pedantic'.  We
  513.      recommend, rather, that users take advantage of the extensions of
  514.      GNU C and disregard the limitations of other compilers.  Aside
  515.      from certain supercomputers and obsolete small machines, there is
  516.      less and less reason ever to use any other C compiler other than
  517.      for bootstrapping GNU CC.
  518.  
  519. `-pedantic-errors'
  520.      Like `-pedantic', except that errors are produced rather than
  521.      warnings.
  522.  
  523. `-W'
  524.      Print extra warning messages for these events:
  525.  
  526.         * A nonvolatile automatic variable might be changed by a call to
  527.           `longjmp'.  These warnings as well are possible only in
  528.           optimizing compilation.
  529.  
  530.           The compiler sees only the calls to `setjmp'.  It cannot know
  531.           where `longjmp' will be called; in fact, a signal handler
  532.           could call it at any point in the code.  As a result, you may
  533.           get a warning even when there is in fact no problem because
  534.           `longjmp' cannot in fact be called at the place which would
  535.           cause a problem.
  536.  
  537.         * A function can return either with or without a value.
  538.           (Falling off the end of the function body is considered
  539.           returning without a value.)  For example, this function would
  540.           evoke such a warning:
  541.  
  542.                foo (a)
  543.                {
  544.                  if (a > 0)
  545.                    return a;
  546.                }
  547.  
  548.         * An expression-statement contains no side effects.
  549.  
  550.         * An unsigned value is compared against zero with `>' or `<='.
  551.  
  552.         * A comparison like `x<=y<=z' appears; this is equivalent to
  553.           `(x<=y ? 1 : 0) <= z', which is a different interpretation
  554.           from that of ordinary mathematical notation.
  555.  
  556.         * Storage-class specifiers like `static' are not the first
  557.           things in a declaration.  According to the C Standard, this
  558.           usage is obsolescent.
  559.  
  560.         * An aggregate has a partly bracketed initializer.  For
  561.           example, the following code would evoke such a warning,
  562.           because braces are missing around the initializer for `x.h':
  563.  
  564.                struct s { int f, g; };
  565.                struct t { struct s h; int i; };
  566.                struct t x = { 1, 2, 3 };
  567.  
  568. `-Wimplicit'
  569.      Warn whenever a function or parameter is implicitly declared.
  570.  
  571. `-Wreturn-type'
  572.      Warn whenever a function is defined with a return-type that
  573.      defaults to `int'.  Also warn about any `return' statement with no
  574.      return-value in a function whose return-type is not `void'.
  575.  
  576. `-Wunused'
  577.      Warn whenever a local variable is unused aside from its
  578.      declaration, whenever a function is declared static but never
  579.      defined, and whenever a statement computes a result that is
  580.      explicitly not used.
  581.  
  582.      If you want to prevent a warning for a particular variable, you
  583.      can use this macro:
  584.  
  585.           #define USE(var) \
  586.             static void * use_##var = (&use_##var, (void *) &var)
  587.           
  588.           USE (string);
  589.  
  590. `-Wswitch'
  591.      Warn whenever a `switch' statement has an index of enumeral type
  592.      and lacks a `case' for one or more of the named codes of that
  593.      enumeration.  (The presence of a `default' label prevents this
  594.      warning.)  `case' labels outside the enumeration range also
  595.      provoke warnings when this option is used.
  596.  
  597. `-Wcomment'
  598.      Warn whenever a comment-start sequence `/*' appears in a comment.
  599.  
  600. `-Wtrigraphs'
  601.      Warn if any trigraphs are encountered (assuming they are enabled).
  602.  
  603. `-Wformat'
  604.      Check calls to `printf' and `scanf', etc., to make sure that the
  605.      arguments supplied have types appropriate to the format string
  606.      specified.
  607.  
  608. `-Wchar-subscripts'
  609.      Warn if an array subscript has type `char'.  This is a common cause
  610.      of error, as programmers often forget that this type is signed on
  611.      some machines.
  612.  
  613. `-Wuninitialized'
  614.      An automatic variable is used without first being initialized.
  615.  
  616.      These warnings are possible only in optimizing compilation,
  617.      because they require data flow information that is computed only
  618.      when optimizing.  If you don't specify `-O', you simply won't get
  619.      these warnings.
  620.  
  621.      These warnings occur only for variables that are candidates for
  622.      register allocation.  Therefore, they do not occur for a variable
  623.      that is declared `volatile', or whose address is taken, or whose
  624.      size is other than 1, 2, 4 or 8 bytes.  Also, they do not occur for
  625.      structures, unions or arrays, even when they are in registers.
  626.  
  627.      Note that there may be no warning about a variable that is used
  628.      only to compute a value that itself is never used, because such
  629.      computations may be deleted by data flow analysis before the
  630.      warnings are printed.
  631.  
  632.      These warnings are made optional because GNU CC is not smart
  633.      enough to see all the reasons why the code might be correct
  634.      despite appearing to have an error.  Here is one example of how
  635.      this can happen:
  636.  
  637.           {
  638.             int x;
  639.             switch (y)
  640.               {
  641.               case 1: x = 1;
  642.                 break;
  643.               case 2: x = 4;
  644.                 break;
  645.               case 3: x = 5;
  646.               }
  647.             foo (x);
  648.           }
  649.  
  650.      If the value of `y' is always 1, 2 or 3, then `x' is always
  651.      initialized, but GNU CC doesn't know this.  Here is another common
  652.      case:
  653.  
  654.           {
  655.             int save_y;
  656.             if (change_y) save_y = y, y = new_y;
  657.             ...
  658.             if (change_y) y = save_y;
  659.           }
  660.  
  661.      This has no bug because `save_y' is used only if it is set.
  662.  
  663.      Some spurious warnings can be avoided if you declare all the
  664.      functions you use that never return as `volatile'.  *Note Function
  665.      Attributes::.
  666.  
  667. `-Wparentheses'
  668.      Warn if parentheses are omitted in certain contexts, such as when
  669.      there is an assignment in a context where a truth value is
  670.      expected, or when operators are nested whose precedence people
  671.      often get confused about.
  672.  
  673. `-Wenum-clash'
  674.      Warn about conversion between different enumeration types.  (C++
  675.      only).
  676.  
  677. `-Wtemplate-debugging'
  678.      When using templates in a C++ program, warn if debugging is not yet
  679.      fully available (C++ only).
  680.  
  681. `-Wall'
  682.      All of the above `-W' options combined.  These are all the options
  683.      which pertain to usage that we recommend avoiding and that we
  684.      believe is easy to avoid, even in conjunction with macros.
  685.  
  686.    The remaining `-W...' options are not implied by `-Wall' because
  687. they warn about constructions that we consider reasonable to use, on
  688. occasion, in clean programs.
  689.  
  690. `-Wtraditional'
  691.      Warn about certain constructs that behave differently in
  692.      traditional and ANSI C.
  693.  
  694.         * Macro arguments occurring within string constants in the
  695.           macro body.  These would substitute the argument in
  696.           traditional C, but are part of the constant in ANSI C.
  697.  
  698.         * A function declared external in one block and then used after
  699.           the end of the block.
  700.  
  701.         * A `switch' statement has an operand of type `long'.
  702.  
  703. `-Wshadow'
  704.      Warn whenever a local variable shadows another local variable.
  705.  
  706. `-Wid-clash-LEN'
  707.      Warn whenever two distinct identifiers match in the first LEN
  708.      characters.  This may help you prepare a program that will compile
  709.      with certain obsolete, brain-damaged compilers.
  710.  
  711. `-Wpointer-arith'
  712.      Warn about anything that depends on the "size of" a function type
  713.      or of `void'.  GNU C assigns these types a size of 1, for
  714.      convenience in calculations with `void *' pointers and pointers to
  715.      functions.
  716.  
  717. `-Wcast-qual'
  718.      Warn whenever a pointer is cast so as to remove a type qualifier
  719.      from the target type.  For example, warn if a `const char *' is
  720.      cast to an ordinary `char *'.
  721.  
  722. `-Wcast-align'
  723.      Warn whenever a pointer is cast such that the required alignment
  724.      of the target is increased.  For example, warn if a `char *' is
  725.      cast to an `int *' on machines where integers can only be accessed
  726.      at two- or four-byte boundaries.
  727.  
  728. `-Wwrite-strings'
  729.      Give string constants the type `const char[LENGTH]' so that
  730.      copying the address of one into a non-`const' `char *' pointer
  731.      will get a warning.  These warnings will help you find at compile
  732.      time code that can try to write into a string constant, but only
  733.      if you have been very careful about using `const' in declarations
  734.      and prototypes.  Otherwise, it will just be a nuisance; this is
  735.      why we did not make `-Wall' request these warnings.
  736.  
  737. `-Wconversion'
  738.      Warn if a prototype causes a type conversion that is different
  739.      from what would happen to the same argument in the absence of a
  740.      prototype.  This includes conversions of fixed point to floating
  741.      and vice versa, and conversions changing the width or signedness
  742.      of a fixed point argument except when the same as the default
  743.      promotion.
  744.  
  745.      Also, warn if a negative integer constant expression is implicitly
  746.      converted to an unsigned type.  For example, warn about the
  747.      assignment `x = -1' if `x' is unsigned.  But do not warn about
  748.      explicit casts like `(unsigned) -1'.
  749.  
  750. `-Waggregate-return'
  751.      Warn if any functions that return structures or unions are defined
  752.      or called.  (In languages where you can return an array, this also
  753.      elicits a warning.)
  754.  
  755. `-Wstrict-prototypes'
  756.      Warn if a function is declared or defined without specifying the
  757.      argument types.  (An old-style function definition is permitted
  758.      without a warning if preceded by a declaration which specifies the
  759.      argument types.)
  760.  
  761. `-Wmissing-prototypes'
  762.      Warn if a global function is defined without a previous prototype
  763.      declaration.  This warning is issued even if the definition itself
  764.      provides a prototype.  The aim is to detect global functions that
  765.      fail to be declared in header files.
  766.  
  767. `-Wredundant-decls'
  768.      Warn if anything is declared more than once in the same scope,
  769.      even in cases where multiple declaration is valid and changes
  770.      nothing.
  771.  
  772. `-Wnested-externs'
  773.      Warn if an `extern' declaration is encountered within an function.
  774.  
  775. `-Winline'
  776.      Warn if a function can not be inlined, and either it was declared
  777.      as inline, or else the `-finline-functions' option was given.
  778.  
  779. `-Woverloaded-virtual'
  780.      Warn when a derived class function declaration may be an error in
  781.      defining a virtual function (C++ only).  In a derived class, the
  782.      definitions of virtual functions must match the type signature of a
  783.      virtual function declared in the base class.  With this option, the
  784.      compiler warns when you define a function with the same name as a
  785.      virtual function, but with a type signature that does not match any
  786.      declarations from the base class.
  787.  
  788. `-Werror'
  789.      Make all warnings into errors.
  790.  
  791. File: gcc.info,  Node: Debugging Options,  Next: Optimize Options,  Prev: Warning Options,  Up: Invoking GCC
  792.  
  793. Options for Debugging Your Program or GNU CC
  794. ============================================
  795.  
  796.    GNU CC has various special options that are used for debugging
  797. either your program or GCC:
  798.  
  799. `-g'
  800.      Produce debugging information in the operating system's native
  801.      format (stabs, COFF, XCOFF, or DWARF).  GDB can work with this
  802.      debugging information.
  803.  
  804.      On most systems that use stabs format, `-g' enables use of extra
  805.      debugging information that only GDB can use; this extra information
  806.      makes debugging work better in GDB but will probably make other
  807.      debuggers crash or refuse to read the program.  If you want to
  808.      control for certain whether to generate the extra information, use
  809.      `-gstabs+', `-gstabs', `-gxcoff+', `-gxcoff', `-gdwarf+', or
  810.      `-gdwarf' (see below).
  811.  
  812.      Unlike most other C compilers, GNU CC allows you to use `-g' with
  813.      `-O'.  The shortcuts taken by optimized code may occasionally
  814.      produce surprising results: some variables you declared may not
  815.      exist at all; flow of control may briefly move where you did not
  816.      expect it; some statements may not be executed because they
  817.      compute constant results or their values were already at hand;
  818.      some statements may execute in different places because they were
  819.      moved out of loops.
  820.  
  821.      Nevertheless it proves possible to debug optimized output.  This
  822.      makes it reasonable to use the optimizer for programs that might
  823.      have bugs.
  824.  
  825.      The following options are useful when GNU CC is generated with the
  826.      capability for more than one debugging format.
  827.  
  828. `-ggdb'
  829.      Produce debugging information in the native format (if that is
  830.      supported), including GDB extensions if at all possible.
  831.  
  832. `-gstabs'
  833.      Produce debugging information in stabs format (if that is
  834.      supported), without GDB extensions.  This is the format used by
  835.      DBX on most BSD systems.  On MIPS and Alpha systems this option
  836.      produces embedded stabs debugging output which is not understood
  837.      by DBX.
  838.  
  839. `-gstabs+'
  840.      Produce debugging information in stabs format (if that is
  841.      supported), using GNU extensions understood only by the GNU
  842.      debugger (GDB).  The use of these extensions is likely to make
  843.      other debuggers crash or refuse to read the program.
  844.  
  845. `-gcoff'
  846.      Produce debugging information in COFF format (if that is
  847.      supported).  This is the format used by SDB on most System V
  848.      systems prior to System V Release 4.
  849.  
  850. `-gxcoff'
  851.      Produce debugging information in XCOFF format (if that is
  852.      supported).  This is the format used by the DBX debugger on IBM
  853.      RS/6000 systems.
  854.  
  855. `-gxcoff+'
  856.      Produce debugging information in XCOFF format (if that is
  857.      supported), using GNU extensions understood only by the GNU
  858.      debugger (GDB).  The use of these extensions is likely to make
  859.      other debuggers crash or refuse to read the program.
  860.  
  861. `-gdwarf'
  862.      Produce debugging information in DWARF format (if that is
  863.      supported).  This is the format used by SDB on most System V
  864.      Release 4 systems.
  865.  
  866. `-gdwarf+'
  867.      Produce debugging information in DWARF format (if that is
  868.      supported), using GNU extensions understood only by the GNU
  869.      debugger (GDB).  The use of these extensions is likely to make
  870.      other debuggers crash or refuse to read the program.
  871.  
  872. `-gLEVEL'
  873. `-ggdbLEVEL'
  874. `-gstabsLEVEL'
  875. `-gcoffLEVEL'
  876. `-gxcoffLEVEL'
  877. `-gdwarfLEVEL'
  878.      Request debugging information and also use LEVEL to specify how
  879.      much information.  The default level is 2.
  880.  
  881.      Level 1 produces minimal information, enough for making backtraces
  882.      in parts of the program that you don't plan to debug.  This
  883.      includes descriptions of functions and external variables, but no
  884.      information about local variables and no line numbers.
  885.  
  886.      Level 3 includes extra information, such as all the macro
  887.      definitions present in the program.  Some debuggers support macro
  888.      expansion when you use `-g3'.
  889.  
  890. `-p'
  891.      Generate extra code to write profile information suitable for the
  892.      analysis program `prof'.  You must use this option when compiling
  893.      the source files you want data about, and you must also use it when
  894.      linking.
  895.  
  896. `-pg'
  897.      Generate extra code to write profile information suitable for the
  898.      analysis program `gprof'.  You must use this option when compiling
  899.      the source files you want data about, and you must also use it when
  900.      linking.
  901.  
  902. `-a'
  903.      Generate extra code to write profile information for basic blocks,
  904.      which will record the number of times each basic block is
  905.      executed, the basic block start address, and the function name
  906.      containing the basic block.  If `-g' is used, the line number and
  907.      filename of the start of the basic block will also be recorded.
  908.      If not overridden by the machine description, the default action is
  909.      to append to the text file `bb.out'.
  910.  
  911.      This data could be analyzed by a program like `tcov'.  Note,
  912.      however, that the format of the data is not what `tcov' expects.
  913.      Eventually GNU `gprof' should be extended to process this data.
  914.  
  915. `-dLETTERS'
  916.      Says to make debugging dumps during compilation at times specified
  917.      by LETTERS.  This is used for debugging the compiler.  The file
  918.      names for most of the dumps are made by appending a word to the
  919.      source file name (e.g.  `foo.c.rtl' or `foo.c.jump').  Here are the
  920.      possible letters for use in LETTERS, and their meanings:
  921.  
  922.     `M'
  923.           Dump all macro definitions, at the end of preprocessing, and
  924.           write no output.
  925.  
  926.     `N'
  927.           Dump all macro names, at the end of preprocessing.
  928.  
  929.     `D'
  930.           Dump all macro definitions, at the end of preprocessing, in
  931.           addition to normal output.
  932.  
  933.     `y'
  934.           Dump debugging information during parsing, to standard error.
  935.  
  936.     `r'
  937.           Dump after RTL generation, to `FILE.rtl'.
  938.  
  939.     `x'
  940.           Just generate RTL for a function instead of compiling it.
  941.           Usually used with `r'.
  942.  
  943.     `j'
  944.           Dump after first jump optimization, to `FILE.jump'.
  945.  
  946.     `s'
  947.           Dump after CSE (including the jump optimization that sometimes
  948.           follows CSE), to `FILE.cse'.
  949.  
  950.     `L'
  951.           Dump after loop optimization, to `FILE.loop'.
  952.  
  953.     `t'
  954.           Dump after the second CSE pass (including the jump
  955.           optimization that sometimes follows CSE), to `FILE.cse2'.
  956.  
  957.     `f'
  958.           Dump after flow analysis, to `FILE.flow'.
  959.  
  960.     `c'
  961.           Dump after instruction combination, to the file
  962.           `FILE.combine'.
  963.  
  964.     `S'
  965.           Dump after the first instruction scheduling pass, to
  966.           `FILE.sched'.
  967.  
  968.     `l'
  969.           Dump after local register allocation, to `FILE.lreg'.
  970.  
  971.     `g'
  972.           Dump after global register allocation, to `FILE.greg'.
  973.  
  974.     `R'
  975.           Dump after the second instruction scheduling pass, to
  976.           `FILE.sched2'.
  977.  
  978.     `J'
  979.           Dump after last jump optimization, to `FILE.jump2'.
  980.  
  981.     `d'
  982.           Dump after delayed branch scheduling, to `FILE.dbr'.
  983.  
  984.     `k'
  985.           Dump after conversion from registers to stack, to
  986.           `FILE.stack'.
  987.  
  988.     `a'
  989.           Produce all the dumps listed above.
  990.  
  991.     `m'
  992.           Print statistics on memory usage, at the end of the run, to
  993.           standard error.
  994.  
  995.     `p'
  996.           Annotate the assembler output with a comment indicating which
  997.           pattern and alternative was used.
  998.  
  999. `-fpretend-float'
  1000.      When running a cross-compiler, pretend that the target machine
  1001.      uses the same floating point format as the host machine.  This
  1002.      causes incorrect output of the actual floating constants, but the
  1003.      actual instruction sequence will probably be the same as GNU CC
  1004.      would make when running on the target machine.
  1005.  
  1006. `-save-temps'
  1007.      Store the usual "temporary" intermediate files permanently; place
  1008.      them in the current directory and name them based on the source
  1009.      file.  Thus, compiling `foo.c' with `-c -save-temps' would produce
  1010.      files `foo.i' and `foo.s', as well as `foo.o'.
  1011.  
  1012. `-print-libgcc-file-name'
  1013.      Print the full absolute name of the library file `libgcc.a' that
  1014.      would be used when linking--and don't do anything else.  With this
  1015.      option, GNU CC does not compile or link anything; it just prints
  1016.      the file name.
  1017.  
  1018.      This is useful when you use `-nostdlib' but you do want to link
  1019.      with `libgcc.a'.  You can do
  1020.  
  1021.           gcc -nostdlib FILES... `gcc -print-libgcc-file-name`
  1022.  
  1023.